import vue from '@vitejs/plugin-vue'

import createAutoImport from './auto-import'
import createSvgIcon from './svg-icon'
import createCompression from './compression'
import createSetupExtend from './setup-extend'
import createThemePlugin from "./theme-scss-vars.js";
import removeNoMatch from "vite-plugin-router-warn";
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from "unplugin-vue-components/resolvers";

export default function createVitePlugins(viteEnv, isBuild = false) {
    return [
        vue(),
        createAutoImport(),
        createSetupExtend(),
        createSvgIcon(isBuild),
        createThemePlugin(),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
        /**
         * 开发环境下移除非必要的vue-router动态路由警告No match found for location with path
         * 非必要具体看 https://github.com/vuejs/router/issues/521 和 https://github.com/vuejs/router/issues/359
         * vite-plugin-router-warn只在开发环境下启用，只处理vue-router文件并且只在服务启动或重启时运行一次，性能消耗可忽略不计
         */
        removeNoMatch(),
        ...createCompression(viteEnv)
    ]
}
